<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--按钮点击时调用方法-->
<input type="button" value="按钮" onclick="f1()">
<script>
  //无参无返回值
  function f1() {
    alert("f1")
  }
  //有参无返回值
  function f2(name,age) {
    alert(name+age);
  }
  //调用方法
  // f1();
  // f2("刘备",30);
  //无参有返回值
  function f3() {
    return "我是返回值"
  }
  let info = f3();
  // alert(info);
  //有参有返回值
  function f4(x,y) {
    return x*y;
  }
  let result = f4(5,9);
  // alert(result);

  //第二种
  let f5 = function (name,age) {
    alert(name+":"+age);
  }
  // f5("关羽",25);
  //第三种
  let f6 = new Function("name","age","alert(name+':'+age)");
  // f6("张飞",18);
</script>
</body>
</html>